import { ADD, ADDNUM, REDUCE, REDUCENUM } from '../types'

const reducer = (state = {
  count: 100
}, action) => {

  switch (action.type) {
    case ADD:
      return { ...state, count: state.count + 1 }
    case ADDNUM:
      return { ...state, count: state.count + action.payload }
    case REDUCE:
      return { ...state, count: state.count - 1 }
    case REDUCENUM:
      return { ...state, count: state.count - action.payload }
    default:
      return state
  }
}

export default reducer
